package com.css.fxfzypg.modules.hypergraph.controller;

import cn.hutool.core.date.DateUtil;
import com.css.fxfzypg.modules.hypergraph.service.HypergraphService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;


/**
 * @author zyt
 * @description   清除超图工作空间临时数据集，每晚3点更新
 */
@Slf4j
@Component
public class HypergraphScheduleTask {

    @Resource
    private HypergraphService hypergraphService;

    @Scheduled(cron = "${schedule.tifcount.clean.temp-dataset-cron}")
    public void deleteWorkspaceDatasetTemp(){
        try {
            hypergraphService.deleteWorkspaceDatasetTemp();
            log.info("[定时任务 - 清除超图工作空间临时数据集 - {}] 表 > {} 清除成功", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
        } catch (Exception e) {
            log.error(e.getMessage(),"[定时任务 - 清除超图工作空间临时数据集 - {}] 表 > {} 清除失败", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));}
    }
}
